async function login() {
  await new Promise((resolve, reject) => {
    //当cookie为1是登陆
    if (getCookie(`login`) == 1) {
      let imgURL = getCookie(`faces`)
      let render = `
      <div data-v-d0cf1686="" data-v-932fe7ba="" class="ypc-popover" placement="right" trigger="hover">
    <div data-v-d0cf1686="" class="ypc-popover-reference">
      <div data-v-932fe7ba="" data-v-d0cf1686="" class="user">
        <!----> <img data-v-932fe7ba="" data-v-d0cf1686=""
          src="../static/faces/${imgURL}"
          alt="avatar-default" class="avatar"> <img data-v-932fe7ba="" data-v-d0cf1686=""
          src="../static/icon-triangle-down.30dbec5.svg" class="arrow">
      </div>
    </div>
    </div>
      `

      $(`.unlogin`).remove()
      $(`.other`).after(render)
    } else {

      let render = `
      <p class="unlogin ypc-link" data-v-932fe7ba="">登录&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;注册</p>
      `
      $(`.ypc-popover`).remove()
      $(`.other`).after(render)
    }

    let loginRender =
      `
    <div data-v-d0cf1686="" class="ypc-popover-popper" style="width: 135px;height: 100px;top: 64px; left: -80px; display: none;">
  <div data-v-932fe7ba="" data-v-d0cf1686="" class="popover">
    <div data-v-932fe7ba="" data-v-d0cf1686="" class="item"><img data-v-932fe7ba="" data-v-d0cf1686=""
        src="../static/icon-user.1df1642.svg" alt="icon" class="icon"> <span
        data-v-932fe7ba="" data-v-d0cf1686="" class="desc">个人中心</span></div>
    <div data-v-932fe7ba="" data-v-d0cf1686="" class="item"><img data-v-932fe7ba="" data-v-d0cf1686=""
        src="../static/icon-exit.b4049f9.svg" alt="icon" class="icon"> <span
        data-v-932fe7ba="" data-v-d0cf1686="" class="desc">退出登录</span></div>
  </div>
  </div>
    `

    // $(`body`).append(loginRender)  

    $(`.ypc-popover`).append(loginRender)

    resolve()
  })

  await mouse()

  await loginClick()
}
login()

function mouse() {
  $(`.ypc-popover`).mouseleave(function () {
    $(`.ypc-popover-popper`).css(`display`, `none`)
  })

  $(`.ypc-popover`).mouseenter(function () {
    $(`.ypc-popover-popper`).css(`display`, `block`)
  })

}

function loginClick() {
  $(`.desc`).eq(0).click(function () {
    window.location.href = `http://127.0.0.1:8080/QQLB/src/pages/QQread-me.html`
  })

  $(`.desc`).eq(1).click(function () {
    deleteCookie(`login`)
    deleteCookie(`username`)
    window.location.href = `http://127.0.0.1:8080/QQLB/src/pages/QQread-home.html`
  })

  $(`.unlogin`).click(function () {
    window.location.href = `http://127.0.0.1:8080/QQLB/src/pages/login.html`
  })
}